#pragma once

#include "vec3f.h"

struct pnt3f final
{
	static const size_t arity = 3;

	float& operator[](const size_t index) { return *(&x + index); }
	float operator[](const size_t index) const { return *(&x + index); }
	bool operator==(const pnt3f rhs) = delete;

	float x;
	float y;
	float z;
};

inline pnt3f pnt3fc(const float x, const float y, const float z)
{
	pnt3f pnt = { x, y, z };
	return pnt;
}

inline pnt3f origin()
{
	return pnt3fc(0, 0, 0);
}

inline pnt3f operator-(const pnt3f lhs, const vec3f rhs)
{
	return pnt3fc(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z);
}

inline vec3f operator-(const pnt3f lhs, const pnt3f rhs)
{
	return vec3fc(lhs.x - rhs.x, lhs.y - rhs.y, lhs.z - rhs.z);
}

inline pnt3f operator+(const vec3f lhs, const pnt3f rhs)
{
	return pnt3fc(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z);
}

inline pnt3f operator+(const pnt3f lhs, const vec3f rhs)
{
	return pnt3fc(lhs.x + rhs.x, lhs.y + rhs.y, lhs.z + rhs.z);
}

inline bool e_null_pnt(const pnt3f p)
{
	return p[0] == 0 && p[1] == 0 && p[2] == 0;
}